﻿//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved

/// <reference path="base-sdk.js" />
/// <reference path="jstoolkit-sdk.js" />

(function () {
    function initialize() {
        var scenarios = [
            "Playback.html" ];
            //"Multitrack.html",
            //"Zoom.html"
       
        // Add any initialization code here
        WinJS.Utilities.query("#scenarios").listen("change", onScenarioChanged);

        var EventListeners = WinJS.Class.mix(WinJS.Class.define(null), WinJS.Utilities.eventMixin);
        sdkSample.events = new EventListeners();
        sdkSample.videoOnError = videoOnError;

        sdkSample.initializeScenarios(scenarios);
    }

    function videoOnError(error) {
        switch (error.target.error.code) {
            case error.target.error.MEDIA_ERR_ABORTED:
                sdkSample.displayError("You aborted the video playback.");
                break;
            case error.target.error.MEDIA_ERR_NETWORK:
                sdkSample.displayError("A network error caused the video download to fail part-way.");
                break;
            case error.target.error.MEDIA_ERR_DECODE:
                sdkSample.displayError("The video playback was aborted due to a corruption problem or because the video used features your browser did not support.");
                break;
            case error.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
                sdkSample.displayError("The video could not be loaded, either because the server or network failed or because the format is not supported.");
                break;
            default:
                sdkSample.displayError("An unknown error occurred.");
                break;
        }    
    }

    function onScenarioChanged() {
        // Do any necessary clean up on the output, the scenario id
        // can be obtained from sdkSample.scenarioId.
        sdkSample.displayStatus("");
        sdkSample.events.dispatchEvent("scenariochanged");
    }

    document.addEventListener("DOMContentLoaded", initialize, false);
})();
